import React from 'react';
import {browserHistory,Link} from 'react-router';
import { Form, Button, Input, Select, message,  Cascader,Modal } from 'antd';
const { TextArea } = Input;
const FormItem = Form.Item;
const Option = Select.Option;
class AddCaseTemplate extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            paths:this.props.location,
            rolesOptions: [],
            type: this.props.params.id,
        }
        this.saveData = this.saveData.bind(this);
        this.cancelSave = this.cancelSave.bind(this);
    }
    componentWillMount() {
    }
    componentDidMount() {
    }
    //保存科室
    saveData(){
        this.props.form.validateFields((err,values)=> {
            console.log(values);
            //发送Ajax请求，将信息post，增加门店信息
        })
    }
    //取消保存
    cancelSave(){
        Modal.confirm({
            title:'取消保存',
            content:'确认取消保存并返回科室列表页面吗？',
            cancelText:'取消',
            okText:'确定',
            onCancel:()=>{console.log('取消')},
            onOk:()=>{
                browserHistory.push('registrationFeeManage');
            }
        })
    }
    render() {
        const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 18 } };
        const formItemLayout1 = { labelCol: { span: 3 }, wrapperCol: { span: 21 } };
        const { getFieldDecorator } = this.props.form;
        return (
            <div className='container'>
                <div className='add-department-box'>
                    <div className="show-template">
                        <span>*新增病例模板</span>
                    </div>
                    <div className='storeRow'>
                        <FormItem {...formItemLayout} label="模板名称" style={{ display: 'inline-block', width: '50%' }} >
                            {getFieldDecorator('templateName', {
                                rules: [{ required: true, message: '模板名称' }],
                            })(
                                <Input placeholder="请输入模板名称" />
                            )}
                        </FormItem>
                        <FormItem {...formItemLayout} label="关联科室" style={{ display: 'inline-block', width: '50%' }} >
                            {getFieldDecorator('relatedDepartment', {
                                initialValue: "1",
                                rules: [{ required: true, message: '关联科室不能为空'}],
                            })(
                                <Select style={{ width: '100% '}}>
                                    <Option value="1">内科</Option>
                                    <Option value="0">外科</Option>
                                </Select>
                            )}
                        </FormItem>
                    </div>
                    <div className='storeRow' >
                        <FormItem {...formItemLayout1} label="主诉" style={{ display: 'inline-block', width: '100%' }} >
                            {getFieldDecorator('mainComplain')(
                                <TextArea  rows={2} />
                            )}
                        </FormItem>
                    </div>
                    <div className='storeRow' >
                        <FormItem {...formItemLayout1} label="现病史" style={{ display: 'inline-block', width: '100%' }} >
                            {getFieldDecorator('nowMedicalHistory')(
                                <TextArea  rows={2} />
                            )}
                        </FormItem>
                    </div>
                    <div className='storeRow' >
                        <FormItem {...formItemLayout1} label="既往史" style={{ display: 'inline-block', width: '100%' }} >
                            {getFieldDecorator('medicalHistory')(
                                <TextArea  rows={2} />
                            )}
                        </FormItem>
                    </div>
                    <div className='storeRow' >
                        <FormItem {...formItemLayout1} label="个人史" style={{ display: 'inline-block', width: '100%' }} >
                            {getFieldDecorator('personHistory')(
                                <TextArea  rows={2} />
                            )}
                        </FormItem>
                    </div>
                    <div className='storeRow' >
                        <FormItem {...formItemLayout1} label="家族史" style={{ display: 'inline-block', width: '100%' }} >
                            {getFieldDecorator('familyHistory')(
                                <TextArea  rows={2}/>
                                )}
                        </FormItem>
                    </div>
                    <div className='storeRow' >
                        <FormItem {...formItemLayout1} label="体格检查" style={{ display: 'inline-block', width: '100%' }} >
                            {getFieldDecorator('bodyCheck')(
                                <TextArea  rows={2} />
                            )}
                        </FormItem>
                    </div>
                    <div className='storeRow' >
                        <FormItem {...formItemLayout1} label="实验室及辅助检查" style={{ display: 'inline-block', width: '100%' }} >
                            {getFieldDecorator('assistantCheck')(
                                <TextArea  rows={2} />
                            )}
                        </FormItem>
                    </div>
                    <div className='storeRow' >
                        <FormItem {...formItemLayout1} label="治疗意见" style={{ display: 'inline-block', width: '100%' }} >
                            {getFieldDecorator('treatOpinion')(
                                <TextArea  rows={2} />
                            )}
                        </FormItem>
                    </div>
                    <div style={{maxWidth:800,textAlign:'right',marginTop:10}}>
                        <Button type='primary' style={{marginRight:15}} onClick={this.saveData}>确定</Button>
                        <Button onClick={this.cancelSave}>取消</Button>
                    </div>
                </div>
            </div>
        )
    }
}
const AddCaseTemplateForm = Form.create()(AddCaseTemplate);
export default AddCaseTemplateForm;